#if 0
#include <iostream>
using namespace std;

int main() {
    int n, m;    cin >> n >> m;
    double sum = 0;
    int t = n - m;
    while (t--)
    {
        double tmp; cin >> tmp;
        sum += tmp;
    }
    double r1 = (sum + m * 1) / n;
    double r2 = (sum + m * 5) / n;
    printf("%.5f %.5f", r1, r2);
}
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 栈排序
     * @param a int整型vector 描述入栈顺序
     * @return int整型vector
     */
    vector<int> solve(vector<int>& a) {
        int tt = a.size(), size = a.size();
        vector<bool> bb(size, false);
        stack<int> tmp;
        vector<int> ret;
        for (int i = 0; i < size; i++) {
            if (a[i] == tt) {
                ret.push_back(a[i]);
                tt--;
                //
                while (bb[tt] == true) {
                    tt--;
                }
                while (tmp.size() && tmp.top() > tt) {
                    ret.push_back(tmp.top());
                    tmp.pop();
                }
            }
            else {
                tmp.push(a[i]);
                bb[a[i]] = true;
            }
        }
        while (tmp.size()) {
            ret.push_back(tmp.top());
            tmp.pop();
        }
        return ret;
    }
};

#endif
#include <iostream>
#include <map>
using namespace std;

int main() {
    map<int, int> mm;
    int n, k;    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int tmp;    cin >> tmp;
        mm[tmp]++;
    }
    int kk = k;
    int tmp, ret = 0;
    for (auto e : mm) {
        k = kk;
        tmp = e.second;
        int pos = e.first;
        for (int i = 1; k > i; i++) {
            // 5 6 7 8
            int tt = min(k / i, mm[pos - i] + mm[pos + i]);
            tmp += tt;
            k -= tt * i;
        }
        ret = max(ret, tmp);
    }
    cout << ret << endl;
}